var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2DataManager = require("DataManager");
var $2Jnk = require("Jnk");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_Dfzd = /* */function (_cc$Component17) {
  babel_inherits(r, _cc$Component17);
  var _super19 = babel_createSuper(r);
  function r() {
    var _this49;
    babel_classCallCheck(this, r);
    _this49 = _super19.apply(this, arguments);
    _this49.speed = 1500;
    _this49.player = null;
    _this49.dir = cc.v2();
    _this49.type = 0;
    _this49.jnk = null;
    _this49.jnk_node = null;
    return _this49;
  }
  babel_createClass(r, [{
    key: "onLoad",
    value: function onLoad() {
      this.player = cc.find("player", this.node.parent.parent.parent);
      var e = this.player.parent.convertToWorldSpaceAR(this.player.position);
      var t = this.node.parent.convertToNodeSpaceAR(e).sub(this.node.position).normalize();
      this.dir = cc.v2(t.x, t.y);
      this.node.scaleX = -this.node.scaleX;
      var a = Math.atan2(this.dir.y, this.dir.x);
      var n = cc.misc.radiansToDegrees(a);
      this.node.angle = n;
      this.jnk_node = cc.instantiate(this.jnk);
      this.jnk_node.parent = this.node.parent;
      this.jnk_node.setPosition(this.node.position);
      this.jnk_node.angle = n - 90;
      this.jnk_node.height = 2001;
      this.node.zIndex = 100;
    }
  }, {
    key: "setType",
    value: function setType(e, t) {
      this.type = e;
      this.speed = t;
      this.generateAllNodes();
    }
  }, {
    key: "generateAllNodes",
    value: function generateAllNodes() {
      var e = ["FX1_1", "FX2_1", "FX3_1", "FX4_1", "FX5_1", "FX6_1", "FX7_1", "FX8_1", "FX9_1", "FX10_1", "FX11_1"];
      var t = this.node.getComponent(sp.Skeleton).attachUtil;
      for (var _a13 = 0; _a13 < e.length; _a13++) {
        var _n23 = t.getAttachedNodes(e[_a13])[0];
        if (_a13 !== this.type) {
          _n23.getChildByName("New Node").active = false;
        } else {
          _n23.getChildByName("New Node").active = true;
        }
      }
    }
  }, {
    key: "update",
    value: function update(e) {
      if ($2DataManager.default.instance.is_over) {
        return;
      }
      if (!this.jnk_node.getComponent($2Jnk.default).state) {
        return;
      }
      var t = this.dir.x * this.speed * e;
      var a = this.dir.y * this.speed * e;
      this.node.x += t;
      this.node.y += a;
      var n = Math.atan2(this.dir.y, this.dir.x);
      var o = cc.misc.radiansToDegrees(n);
      this.node.angle = o;
      this.node.position.sub(this.node.parent.position).mag() > cc.winSize.width + cc.winSize.height + 2500 && this.node.removeFromParent();
    }
  }]);
  return r;
}(cc.Component);
cc__decorate([ccp_property(cc.Prefab)], def_Dfzd.prototype, "jnk", undefined);
def_Dfzd = cc__decorate([ccp_ccclass], def_Dfzd);
exports.default = def_Dfzd;